<!DOCTYPE html>
<html>
    <head>
        <style type="text/css">
            body{
                background-color: black;
            }
            .images{
                width: 300px;
                height: 300px;
                display: grid;
                grid-template-columns: repeat(3,1fr);
            }
            .img{
                background-size: 300px 300px;
                transition: 0.5s;
                box-shadow: inset 0 0 1px #fff;
                position: relative;
                background-image:url("./demo.png");
            }
            .img:nth-child(3n+1){
                background-position-x: 0;
                left: -20px;
            }
            .img:nth-child(3n+2){
                background-position-x: -100%;
                left: 0;
            }
            .img:nth-child(3n){
                background-position-x: -200%;
                left: 20px;
            }
            .img:nth-child(n+7){
                background-position-y: -200%;
                top: 20px;
            }
            .img:nth-child(-n+6){
                background-position-y: -100%;
                top: 0;
            }
            .img:nth-child(-n+3){
                background-position-y: 0;
                top: -20px;
            }
            .images:hover .img{
                box-shadow: inset 0 0 0 #fff;
                left: 0;top: 0;
            }

        </style>
    </head>
    <body>
        <div class="images">
            <div class="img"></div>
            <div class="img"></div>
            <div class="img"></div>
            <div class="img"></div>
            <div class="img"></div>
            <div class="img"></div>
            <div class="img"></div>
            <div class="img"></div>
            <div class="img"></div>
        </div>
    </body>
</html>
